Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
portal-vue
Advanced tools
> A Portal Component for Vuejs, to render DOM outside of a component, anywhere in the document.
portal-vue is a Vue.js plugin that allows you to render a component's template in a different part of the DOM tree. This can be particularly useful for creating modals, tooltips, and other UI elements that need to be rendered outside of their parent component's DOM hierarchy.
Basic Portal
This feature allows you to move a piece of the template to another part of the DOM. The `portal` component is used to specify the content to be moved and the `to` attribute specifies the target element.
<template>
<div>
<portal to="destination">
<p>This content will be teleported to the destination element.</p>
</portal>
<div id="destination"></div>
</div>
</template>
<script>
import { Portal } from 'portal-vue';
export default {
components: {
Portal
}
};
</script>
Named Portals
Named portals allow you to manage multiple portals more easily by giving each portal a unique name.
<template>
<div>
<portal to="destination" name="example">
<p>This content will be teleported to the destination element with a specific name.</p>
</portal>
<div id="destination"></div>
</div>
</template>
<script>
import { Portal } from 'portal-vue';
export default {
components: {
Portal
}
};
</script>
Scoped Slots
Scoped slots allow you to pass data from the parent component to the teleported content, making it more dynamic and interactive.
<template>
<div>
<portal to="destination" v-slot="props">
<p>{{ props.message }}</p>
</portal>
<div id="destination"></div>
</div>
</template>
<script>
import { Portal } from 'portal-vue';
export default {
components: {
Portal
},
data() {
return {
message: 'This is a scoped slot message.'
};
}
};
</script>
react-portal is a React library that provides similar functionality to portal-vue for React applications. It allows you to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
A Portal Component for Vuejs, to render DOM outside of a component, anywhere in the document.
For more detailed documentation and additional Information, please visit the docs.
Looking for version 1.*? Docs for version 1 are here
npm i portal-vue
# or
yarn add portal-vue
import PortalVue from 'portal-vue'
Vue.use(PortalVue)
<portal to="destination">
<p>This slot content will be rendered wherever the <portal-target> with name 'destination'
is located.</p>
</portal>
<portal-target name="destination">
<!--
This component can be located anywhere in your App.
The slot content of the above portal component will be rendered here.
-->
</portal-target>
Add portal-vue/nuxt
to modules section of nuxt.config.js
{
modules: ['portal-vue/nuxt']
}
FAQs
> A Portal Component for Vue 3, to render DOM outside of a component, anywhere in the document.
The npm package portal-vue receives a total of 485,716 weekly downloads. As such, portal-vue popularity was classified as popular.
We found that portal-vue demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.